/*
 * Copyright (C) 2007-2008 SlideMe client
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.slideme.android.manager;

import android.content.Context;
import android.content.pm.PackageManager;

import java.io.IOException;
import java.net.URI;

/**
 * A service for downloading of content for a specific mime-type.
 */
public interface ContentHandler {

    /**
     * The mime-type that this handler handles
     *
     * @return mime-type that this handler handles
     */
    String getMimeType();

    /**
     * Downloads the content from the specified URI to the fileName on the local system.
     *
     * @param uri            uri of the remote content
     * @param fileName       the file name of the stored content
     * @param packageManager the package manager
     * @throws IOException if there is an I/O problem in the download
     */
    void download(URI uri, String fileName, PackageManager packageManager) throws IOException;

    /**
     * Initialize the content handler
     *
     * @param context the android content context
     */
    void init(Context context);
}
